﻿/************************************************

* Function： N/A
* Name： DamageNumberRenderFeature
*
* Ver       Time                     Author
* 0.10      2023/1/12 10:00:05       ake
*
**************************************************/


using UnityEngine;
using UnityEngine.Rendering.Universal;

namespace Common
{
    public class DamageNumberRenderFeature: ScriptableRendererFeature
    {

        /// <summary>
        /// 和官方的一样用来表示什么时候插入Pass，默认在渲染完不透明物体后
        /// </summary>
        public RenderPassEvent Event = RenderPassEvent.AfterRenderingPostProcessing;

        private DamageNumberRenderPass _scriptablePass;

        public override void Create()
        {
            if (_scriptablePass == null)
            {
                _scriptablePass = new DamageNumberRenderPass(Event);
            }
        }

        public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
        {
            if (_scriptablePass == null) return;
            renderer.EnqueuePass(_scriptablePass);
        }

        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
            _scriptablePass = null;
        }
    }
}

